package com.itheima.lambdademo.test4;

public class CalculatorDemo {
    public static void main(String[] args) {
        int i = useCalculator(new Calculator() {
            @Override
            public int calc(int a, int b) {
                return a + b;
            }
        }, 10, 20);
        System.out.println(i);

        int i1 = useCalculator((a, b) -> a + b, 20, 50);
        System.out.println(i1);
    }

    public static int useCalculator(Calculator calculator, int a, int b) {
        return calculator.calc(a, b);
    }
}

interface Calculator {
    public abstract int calc(int a, int b);
}